const VideoFrameExtractor = require('../utils/ExtractVideoFrames');

const extractFramesFn = async (event, config, defaultFfmpegPath, mainWindow) => {
  try {
    // 创建视频帧提取器实例
    const extractor = new VideoFrameExtractor(config);
    
    // 配置FFmpeg路径
    if (config.ffmpegExecPath) {
      extractor.configureFfmpeg(config.ffmpegExecPath);
    } else {
      extractor.configureFfmpeg(defaultFfmpegPath);
    }
    
    // 执行提取
    const result = await extractor.extractFrames(mainWindow);
    return result;
  } catch (error) {
    console.error('提取视频帧失败:', error);
    throw error;
  }
};

module.exports = {
  extractFramesFn
};
